<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-TAG/platForm.tld" prefix="PF"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<PF:basePath/>">
		<title>工程</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<jsp:include page="/WEB-FACE/conf/includeH.jsp"></jsp:include>
		<link rel="stylesheet" type="text/css"
			href="WEB-FACE/model/kindeditor/themes/default/default.css">
		<script type="text/javascript"
			src="WEB-FACE/model/kindeditor/kindeditor-all-min.js"></script>
		<script type="text/javascript"
			src="WEB-FACE/model/kindeditor/zh_CN.js"></script>
	</head>
	<body class="easyui-layout">
		<div data-options="region:'west',split:true,border:false"
			style="width: 250px;">
			<div class="TREE_COMMON_BOX_SPLIT_DIV">
				<a id="a_tree_reload" href="javascript:void(0)"
					class="easyui-linkbutton" data-options="plain:true"
					iconCls="icon-reload">刷新菜单</a>
				<a id="a_tree_openAll" href="javascript:void(0)"
					class="easyui-linkbutton" data-options="plain:true"
					iconCls="icon-sitemap">全部展开</a>
			</div>
			<ul id="tt"></ul>
		</div>
		<div data-options="region:'center',border:false">
			<table id="dom_datagridfarmcodeproject">
				<thead>
					<tr>
						<th data-options="field:'ck',checkbox:true"></th>
						<th field="NAME" data-options="sortable:true" width="80">
							工程名称
						</th>
						<th field="PSTATE" data-options="sortable:true" width="80">
							状态
						</th>
						<th field="TYPE" data-options="sortable:true" width="80">
							向导类型
						</th>
						<th field="PCONTENT" data-options="sortable:true" width="280">
							备注
						</th>
					</tr>
				</thead>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	var url_delActionfarmcodeproject = "admin/FarmCodeProjectdeleteCommit.do";//删除URL
	var url_formActionfarmcodeproject = "admin/FarmCodeProjectshow.do";//增加、修改、查看URL
	var url_searchActionfarmcodeproject = "admin/FarmCodeProjectqueryAll.do";//查询URL
	var url_delActionfarmcodetype = "admin/FarmCodeTypedeleteCommit.do";//删除URL
	var url_formActionfarmcodetype = "admin/FarmCodeTypeshow.do";//增加、修改、查看URL
	var url_searchActionfarmcodetype = "admin/FarmCodeTypequeryAll.do";//查询URL
	var title_windowfarmcodeproject = "工程";//功能名称
	var gridfarmcodeproject;//数据表格对象
	var currentType;
	var currentTypeName;
	var TOOL_BARfarmcodeproject = [ {
		id : 'add',
		text : '新增工程',
		iconCls : 'icon-add',
		handler : addDatafarmcodeproject
	}, {
		id : 'edit',
		text : '修改工程',
		iconCls : 'icon-edit',
		handler : editDatafarmcodeproject
	}, {
		id : 'del',
		text : '删除工程',
		iconCls : 'icon-remove',
		handler : delDatafarmcodeproject
	}, {
		id : 'del',
		text : '配置工程',
		iconCls : 'icon-settings',
		handler : settingDatafarmcodeproject
	}, {
		id : 'edit',
		text : '增加根分类',
		iconCls : 'icon-category',
		handler : addRootDatafarmcodetype
	}, {
		id : 'edit',
		text : '增加分类',
		iconCls : 'icon-category',
		handler : addDatafarmcodetype
	}, {
		id : 'edit',
		text : '修改分类',
		iconCls : 'icon-category',
		handler : editDatafarmcodetype
	}, {
		id : 'del',
		text : '删除分类',
		iconCls : 'icon-category',
		handler : delDatafarmcodetype
	} ];
	$(function() {
		//初始化数据表格
		gridfarmcodeproject = $('#dom_datagridfarmcodeproject').datagrid( {
			url : url_searchActionfarmcodeproject,
			fit : true,
			fitColumns : true,
			'toolbar' : TOOL_BARfarmcodeproject,
			pagination : true,
			closable : true,
			checkOnSelect : true,
			striped : true,
			rownumbers : true,
			border : false,
			ctrlSelect : true
		});
		$('#tt').tree( {
			url : 'admin/FarmCodeTypeLoadTreeNode.do',
			onSelect : function(node) {
				currentType = node.id;
				currentTypeName = node.text;
				$(gridfarmcodeproject).datagrid('load', {
					parentId : node.id
				});
			}
		});
		$('#a_tree_reload').bind('click', function() {
			$('#tt').tree('reload');
		});
		$('#a_tree_openAll').bind('click', function() {
			$('#tt').tree('expandAll');
		});
	});
	//查看
	function viewDatafarmcodeproject() {
		var selectedArray = $(gridfarmcodeproject).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionfarmcodeproject + '?pageset.pageType='
					+ PAGETYPE.VIEW + '&ids=' + selectedArray[0].ID;
			$.farm.openWindow( {
				id : 'winfarmcodeproject',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '浏览'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//配置工程
	function settingDatafarmcodeproject() {
		var selectedArray = $(gridfarmcodeproject).datagrid('getSelections');
		if (selectedArray.length == 1) {
			window.parent
					.openUrlAtIfram(
							'admin/FarmCodePackage_ACTION_CONSOLE.do?ids=' + selectedArray[0].ID,
							selectedArray[0].NAME + '工程配置',
							selectedArray[0].NAME + '工程配置', true);
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}

	//新增
	function addDatafarmcodeproject() {
		if (!currentType) {
			$.messager.alert(MESSAGE_PLAT.PROMPT, "请选择一个分类", 'info');
			return;
		}
		var url = url_formActionfarmcodeproject + '?parentId=' + currentType
				+ '&pageset.pageType=' + PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winfarmcodeproject',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改
	function editDatafarmcodeproject() {
		var selectedArray = $(gridfarmcodeproject).datagrid('getSelections');
		if (selectedArray.length == 1) {
			var url = url_formActionfarmcodeproject + '?pageset.pageType='
					+ PAGETYPE.EDIT + '&ids=' + selectedArray[0].ID;
			;
			$.farm.openWindow( {
				id : 'winfarmcodeproject',
				width : 600,
				height : 300,
				modal : true,
				url : url,
				title : '修改'
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE_ONLY,
					'info');
		}
	}
	//删除
	function delDatafarmcodeproject() {
		var selectedArray = $(gridfarmcodeproject).datagrid('getSelections');
		if (selectedArray.length > 0) {
			// 有数据执行操作
			var str = selectedArray.length + MESSAGE_PLAT.SUCCESS_DEL_NEXT_IS;
			$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
				if (flag) {
					$(gridfarmcodeproject).datagrid('loading');
					$.post(url_delActionfarmcodeproject + '?ids='
							+ $.farm.getCheckedIds(gridfarmcodeproject), {},
							function(flag) {
								$(gridfarmcodeproject).datagrid('loaded');
								if (flag.pageset.commitType == 0) {
									$(gridfarmcodeproject).datagrid('reload');
								} else {
									var str = MESSAGE_PLAT.ERROR_SUBMIT
											+ flag.pageset.message;
									$.messager.alert(MESSAGE_PLAT.ERROR, str,
											'error');
								}
							});
				}
			});
		} else {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
		}
	}
	//新增根分类
	function addRootDatafarmcodetype() {
		var url = url_formActionfarmcodetype + '?pageset.pageType='
				+ PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winfarmcodeproject',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//新增分类
	function addDatafarmcodetype() {
		var url = url_formActionfarmcodetype + '?parentId=' + currentType
				+ '&pageset.pageType=' + PAGETYPE.ADD;
		$.farm.openWindow( {
			id : 'winfarmcodeproject',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '新增'
		});
	}
	//修改分类
	function editDatafarmcodetype() {
		if (!currentType) {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
			return;
		}
		var url = url_formActionfarmcodetype + '?ids=' + currentType
				+ '&pageset.pageType=' + PAGETYPE.EDIT;
		$.farm.openWindow( {
			id : 'winfarmcodeproject',
			width : 600,
			height : 300,
			modal : true,
			url : url,
			title : '修改'
		});
	}
	//删除分类
	function delDatafarmcodetype() {
		if (!currentType) {
			$.messager.alert(MESSAGE_PLAT.PROMPT, MESSAGE_PLAT.CHOOSE_ONE,
					'info');
			return;
		}
		// 有数据执行操作
		var str = "分类" + currentTypeName + "将被删除是否继续?";
		$.messager.confirm(MESSAGE_PLAT.PROMPT, str, function(flag) {
			if (flag) {
				$.post(url_delActionfarmcodetype + '?ids=' + currentType, {},
						function(flag) {
							if (flag.pageset.commitType == 0) {
								$('#tt').tree('reload');
							} else {
								var str = MESSAGE_PLAT.ERROR_SUBMIT
										+ flag.pageset.message;
								$.messager.alert(MESSAGE_PLAT.ERROR, str,
										'error');
							}
						});
			}
		});
	}
</script>
</html>




